# -*- coding: utf-8 -*-
#人员证书等级
import json

def getPersonLevelList(request):
    request.cursor_standard.execute(request.formatSql('''
        select * 
        from standard.dict_person_apt_level
        where is_del = 'N' 
        order by level_class,class2,level_order
    '''))
    rows = request.cursor_standard.fetchall()
    return json.dumps(rows, ensure_ascii=False)

def insertPersonLevel(request):
    request.cursor_standard.execute(request.formatSql('''
        insert into dict_person_apt_level(level_name,level_order,level_class,level_alias)
		values('${level_name}','${level_order}','${level_class}','${level_alias}')
    '''))
    return str(request.cursor_standard.rowcount)

def updatePersonLevel(request):
    request.cursor_standard.execute(request.formatSql('''
        update dict_person_apt_level 
		set level_name = '${level_name}',
            level_order = '${level_order}',
            level_class='${level_class}',
            level_alias = '${level_alias}'  
		where level_id = ${level_id}
    '''))
    return str(request.cursor_standard.rowcount)

def deletePersonLevel(request):
    request.cursor_standard.execute(request.formatSql('''
        update  dict_person_apt_level 
        set is_del = 'Y' 
        where level_id = '${level_id}' 
    '''))
    return str(request.cursor_standard.rowcount)